<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>数据更新</title>
        <style>
            table, th, td {
              border: 1px solid black;
              border-collapse: collapse;
            }
            th, td {
              padding: 1px;
              text-align: left;
            }
        </style>
        <script>
            function getCurDate(){
                const timeElapsed = Date.now();
                const today = new Date(timeElapsed);
                today_str = today.toLocaleDateString();
                
                document.getElementById("curDate").innerHTML=today_str;
                // console.log('today')
            }

            $('button1').onclick(
                function(){
                    console.log("hello!");
                    location.href='127.0.0.1:8000/data/update';
                }
            )
        </script>
    </head>
    <body>
        <section>
            <h5>数据日期</h4>
                <p>
                    今天:{{now_date}} | 上次:{{last_date}}
                </p>
            <ul>
                <li>可更新交易日:{{update_daynum}}天</li>
                <li>
                    <form action="{% url 'webIndex:data_update_btn_exec' %}" method="get">
                        <button type="submit">数据更新</button>
                    </form>
                </li>
            </ul>

            
        </section>
        <!-- <button type="button" id="button1">数据刷新</button> -->
        <!-- <button style="text-align: right" type="button" onclick="">更新数据</button> -->
        <section>
            <h5>市场统计({{last_date}})</h4>
            <table style="width:100%">
                <!-- <caption style="text-align: center;">股票总体分布</caption> -->
                <tr>
                    <th>正常</th>
                    <th>沪市</th>
                    <th>深市</th>
                    <th>创业</th>
                    <th>科创</th>
                    <th>全部</th>
                </tr>
                <tr>
                    <td>{{table_stocknum.normal}}</td> 
                    <td>{{table_stocknum.sh}}</td>
                    <td>{{table_stocknum.sz}}</td>
                    <td>{{table_stocknum.cy}}</td>
                    <td>{{table_stocknum.kc}}</td>
                    <td>{{table_stocknum.all}}</td>
                </tr>
            </table>
        </section>
        <hr>
        <!-- <p id="curDate">当前日期</p> -->
        <h6>更新周期:{{start_date}}~{{end_date}}</h6>
        <section>
            <h6>即将上市股票数量:{{next_stocklist|length}}</h6>
            <table style="width:100%">
                <!-- <caption style="text-align: center;">股票总体分布</caption> -->
                <tr>
                    <th>名称</th>
                    <th>代码</th>
                    <th>上市日期</th>
                </tr>
                {% for stock in next_stocklist %}
                <tr>
                    <td>{{stock.name}}</td>
                    <td>{{stock.code}}</td>
                    <td>{{stock.list_date}}</td>
                </tr>
                {% endfor  %}
            </table>
        </section>
        <hr>
        <section>
            <h6>新上市股票数量：{{new_stocklist|length}}</h6>
            <table style="width:100%">
                <!-- <caption style="text-align: center;">股票总体分布</caption> -->
                <tr>
                    <th>名称</th>
                    <th>代码</th>
                    <th>上市日期</th>
                </tr>
                {% for stock in new_stocklist %}
                <tr>
                    <td>{{stock.name}}</td>
                    <td>{{stock.code}}</td>
                    <td>{{stock.list_date}}</td>
                </tr>
                {% endfor  %}
            </table>
        </section> 
        <hr>     
        <section>
            <h6>摘帽股票数量:{{dest_stocklist|length}}</h6>
            <table style="width:100%">
                <!-- <caption style="text-align: center;">股票总体分布</caption> -->
                <tr>
                    <th>名称</th>
                    <th>代码</th>
                    <th>上市日期</th>
                </tr>
                {% for stock in dest_stocklist %}
                <tr>
                    <td>{{stock.name}}</td>
                    <td>{{stock.code}}</td>
                    <td>{{stock.list_date}}</td>
                </tr>
                {% endfor  %}
            </table>
        </section>
        <hr>
        <section>
            <h6>退出股票数量:{{del_stocklist|length}}</h6>
            <ul>
                {% for stock in del_stocklist %}
                <li>{{stock.code}}  {{stock.name}}  {{stock.type}}</li>
                {% endfor  %}
            </ul>
        </section>
    </body>
</html>    